import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wch/constant/config_constant.dart';
import 'package:wch/page/setting.dart';
import 'package:wch/utils/navigator_utils.dart';
import 'package:wch/widget/business_widget.dart';
import 'package:wch/widget/common_widget.dart';
import 'package:wch/widget/padding_widget.dart';

import '../constant/resource_constant.dart';
import '../widget/alert_view.dart';
import '../widget/text_widget.dart';

class AboutPage extends StatefulWidget {
  const AboutPage({super.key});

  @override
  State<AboutPage> createState() => _AboutPageState();
}

class _AboutPageState extends State<AboutPage> {
  OverlayEntry? entry;

  @override
  void initState() {
    super.initState();

  }

  @override
  Widget build(BuildContext context) {
    return CommonScaffold(title: '关于', body: Container(
      padding: EdgeInsets.symmetric(horizontal: 15.w),
      margin: EdgeInsets.symmetric(horizontal: 15.w, vertical: 15.h),
      height: 52.h*3+1,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(7.5.w)),
        color: Colors.white
      ),
      child: Column(
        children: [
          // CommonInputWidget.getSetSelectWidget('版本号', ''),
          InkWell(onTap: (){
            entry = OverlayEntry(builder: (ctx){
              return AboutAlert(entry: entry!);
            });
            Overlay.of(context).insert(entry!);
          }, child: getVersionSelectWidget('版本号', '')),
          LineWidget(width: ScreenUtil().screenWidth-30.w, height: 0.5),
          InkWell(onTap: (){
            entry = OverlayEntry(builder: (ctx){
              return ProtocolAlert(entry: entry!, title: '《用户协议条款》', htmlStr: agreementStr,);
            });
            Overlay.of(context).insert(entry!);
          }, child: CommonInputWidget.getSetSelectWidget('《用户协议条款》', '')),
          LineWidget(width: ScreenUtil().screenWidth-30.w, height: 0.5),
          InkWell(onTap: (){
            entry = OverlayEntry(builder: (ctx){
              return ProtocolAlert(entry: entry!, title: '《隐私政策条款》', htmlStr: privacyStr,);
            });
            Overlay.of(context).insert(entry!);
          }, child: CommonInputWidget.getSetSelectWidget('《隐私政策条款》', '')),
        ],
      ),
    ));
  }

  Widget getVersionSelectWidget(String label, String content) {
    return Container(
      height: 52.h,
      child: Row(
        children: [
          Container(
            width: 127.w,
            child: F15TitleText(label, color: F1TextColor),
          ),
          Expanded(child: Container(),),
          F15TitleText(content, color: F1TextColor),
          HorPadding(15.w),
          Image.asset(
            arrowRightPng,
            width: 11.w,
            height: 11.w,
          )
        ],
      ),
    );
  }
}
